//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_STL_Core.h".
//-------------------------------------------------------------------

#ifndef _UXS_LIBC_IO_H
#define _UXS_LIBC_IO_H

#pragma once

#ifdef __PACKING
#pragma pack(push,__PACKING)
#endif

#ifdef  __cplusplus
extern "C" {
#endif
	

enum {

	/* Buffered I/O macros */

	BUFSIZ		= 512,
	
	/* Seek method constants */

	SEEK_CUR	= 1,
	SEEK_END    = 2,
	SEEK_SET    = 0,
	
	FILENAME_MAX	= 260,
	FOPEN_MAX		= 20,
};


struct _iobuf {
        char *_ptr;
        int   _cnt;
        char *_base;
        int   _flag;
        int   _file;
        int   _charbuf;
        int   _bufsiz;
        char *_tmpfname;
        };
typedef struct _iobuf FILE;

typedef unsigned short wint_t;
typedef unsigned short wctype_t;


#if     defined (_POSIX_)
typedef long fpos_t;
#define _FPOSOFF(fp) ((long)(fp))
#else   /* _POSIX_ */

#if     !__STDC__
typedef __INT64 fpos_t;
#define _FPOSOFF(fp) ((long)(fp))
#else
typedef __INT64 fpos_t;
#define _FPOSOFF(fp) ((long)(fp))
#endif
#endif  /* _POSIX_ */


//void __CDECL clearerr(FILE * _File);
int __CDECL fclose(FILE * _File);

//int __CDECL feof(FILE * _File);
//int __CDECL ferror(FILE * _File);
int __CDECL fflush(FILE * _File);
//int __CDECL fgetc(FILE * _File);
int __CDECL _fgetchar(void);
//int __CDECL fgetpos(FILE * _File , fpos_t * _Pos);
//char * __CDECL fgets(char * _Buf, int _MaxCount, FILE * _File);
//int __CDECL fgetpos(FILE * _File , fpos_t * _Pos);
//char * __CDECL fgets(char * _Buf, int _MaxCount, FILE * _File);

FILE * __CDECL fopen(const char * _Filename, const char * _Mode);
int __CDECL fprintf(FILE * _File, const char * _Format, ...);
//int __CDECL fputc(int _Ch, FILE * _File);
//int __CDECL fputs(const char * _Str, FILE * _File);
size_t __CDECL fread(void * _DstBuf, size_t _ElementSize, size_t _Count, FILE * _File);
//FILE * __CDECL (const char * _Filename, const char * _Mode, FILE * _File);
int __CDECL fscanf(FILE * _File, const char * _Format, ...);
//int __CDECL fsetpos(FILE * _File, const fpos_t * _Pos);
int __CDECL fseek(FILE * _File,  long _Offset, int _Origin);
long __CDECL ftell(FILE * _File);

int __CDECL _fseeki64(FILE * _File, __INT64 _Offset, int _Origin);
__INT64 __CDECL _ftelli64(FILE * _File);

size_t __CDECL fwrite(const void * _Str, size_t _Size, size_t _Count, FILE * _File);
//int __CDECL getc(FILE * _File);
int __CDECL getchar(void);

int __CDECL printf(const char * _Format, ...);
//int __CDECL putc( int _Ch, FILE * _File);
int __CDECL putchar(int _Ch);
int __CDECL puts(const char * _Str);
int __CDECL _putw(int _Word, FILE * _File);

int __CDECL remove(const char * _Filename);
int __CDECL rename(const char * _OldFilename, const char * _NewFilename);
int __CDECL unlink(const char * _Filename);
//void __CDECL rewind(FILE * _File);
int __CDECL scanf(const char * _Format, ...);
int __CDECL sscanf(const char * _Src, const char * _Format, ...);
//FILE * __CDECL tmpfile(void);


wint_t __CDECL fgetwc(FILE * _File);
wint_t __CDECL fputwc(wchar_t _Ch, FILE * _File);
wint_t __CDECL getwc(FILE * _File);
wint_t __CDECL getwchar(void);
wint_t __CDECL putwc(wchar_t _Ch, FILE * _File);
wint_t __CDECL putwchar(wchar_t _Ch);
wint_t __CDECL ungetwc(wint_t _Ch, FILE * _File);
int __CDECL fwprintf(FILE * _File, const wchar_t * _Format, ...);
int __CDECL wprintf(const wchar_t * _Format, ...);

//int __CDECL vfwprintf(FILE * _File, const wchar_t * _Format, va_list _ArgList);
//int __CDECL vwprintf(const wchar_t * _Format, va_list _ArgList);


#ifdef  __cplusplus
} // extern "C"
#endif

#ifdef __PACKING
#pragma pack(pop)
#endif

#endif	// _UXS_LIBC_IO_H